"use strict";
cc._RF.push(module, '8bc0erOHapBNL45QQzX39t9', 'native');
// scripts/engines/services/miniGameContent/native/native.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
Object.defineProperty(exports, "__esModule", { value: true });
var miniApp_1 = require("../miniApp");
//
// window['lookOverF'] = null;
// export function androidCallVideoOver(){
//     window['lookOverF']  && window['lookOverF'] ();
// }
var NativeApi = /** @class */ (function (_super) {
    __extends(NativeApi, _super);
    function NativeApi() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.m_appId = '205615';
        _this.m_secret = '';
        _this.m_adUnitId = '945669906';
        return _this;
    }
    NativeApi.prototype.navigateToMiniGame = function (appId, successCallback, failCallback) {
        console.error('#23102559 未实现跳转');
    };
    NativeApi.prototype.drawHead = function (headUrl) {
        return Promise.resolve(undefined);
    };
    NativeApi.prototype.fullScreenVideo = function () {
        return __awaiter(this, void 0, Promise, function () {
            return __generator(this, function (_a) {
                //
                switch (cc.sys.os) {
                    case cc.sys.OS_ANDROID: {
                        return [2 /*return*/, Promise.resolve()];
                    }
                    case cc.sys.OS_IOS: {
                        console.log('cocos SDK 调用苹果 全屏视频');
                        //苹果代码并没有使用此ID
                        return [2 /*return*/, new Promise(function (resolve) {
                                //@ts-ignore
                                jsb.reflection.callStaticMethod('RootViewController', 'loadFullScreenVideo');
                                resolve();
                            })];
                    }
                    default: {
                        return [2 /*return*/, Promise.resolve()];
                    }
                }
                return [2 /*return*/];
            });
        });
    };
    NativeApi.prototype.commitRank = function (rankId, score) {
        return __awaiter(this, void 0, Promise, function () {
            return __generator(this, function (_a) {
                return [2 /*return*/, Promise.resolve(false)];
            });
        });
    };
    NativeApi.prototype.showRank = function (rankId) {
        return __awaiter(this, void 0, Promise, function () {
            return __generator(this, function (_a) {
                return [2 /*return*/, Promise.resolve(false)];
            });
        });
    };
    NativeApi.prototype.LocalInBlockCityList = function () {
        return false;
    };
    NativeApi.prototype.vibrate = function (type) {
    };
    NativeApi.prototype.showBannerAD = function (node, successCallback, errorCallback, onCloseCallBack, setBannerPosition) {
        throw new Error("Method not implemented.");
    };
    NativeApi.prototype.hideBanner = function () {
        throw new Error("Method not implemented.");
    };
    NativeApi.prototype.showInterstitialAd = function (onAdClose, onFailed) {
        throw new Error("Method not implemented.");
    };
    NativeApi.prototype.showNativeAd = function (successCallback, errorCallback, completeCallback) {
        throw new Error("Method not implemented.");
    };
    NativeApi.prototype.reportAdClickNativeAd = function () {
        throw new Error("Method not implemented.");
    };
    NativeApi.prototype.createMoreGameBtn = function () {
        throw new Error("Method not implemented.");
    };
    NativeApi.prototype.addShortcut = function () {
        throw new Error("Method not implemented.");
    };
    NativeApi.prototype.operateGameLive = function () {
        throw new Error("Method not implemented.");
    };
    NativeApi.prototype.getShareVideoRank = function (sortType, successCb) {
        throw new Error("Method not implemented.");
    };
    NativeApi.prototype.drawUrlImage = function (url, overCb) {
        throw new Error("Method not implemented.");
    };
    NativeApi.prototype.showVideo = function (videoUrl) {
        throw new Error("Method not implemented.");
    };
    NativeApi.prototype.subscribeMessage = function (successCallback, failCallback, completeCallback) {
        throw new Error("Method not implemented.");
    };
    NativeApi.prototype.showAddFavoriteGuide = function (successCallback, failCallback, completeCallback) {
        throw new Error("Method not implemented.");
    };
    NativeApi.prototype.StartRecordSound = function () {
        throw new Error("Method not implemented.");
    };
    NativeApi.prototype.StopRecordSound = function (successCallback) {
        throw new Error("Method not implemented.");
    };
    NativeApi.prototype.PlayLastRecordSound = function (scale, successCb, errorCb) {
        throw new Error("Method not implemented.");
    };
    NativeApi.getRandNameAndUrl = function () {
        var user = {
            nickName: "\u96F6\u4E00\u4FA0",
            avatarUrl: null,
            language: 'ch',
            gender: 0,
            country: '中国',
            province: '',
            city: '',
        };
        return user;
    };
    ;
    NativeApi.prototype.validAppId = function () {
    };
    NativeApi.prototype.getUserInfo = function (params) {
        params.success && params.success({ userInfo: NativeApi.getRandNameAndUrl() });
    };
    NativeApi.prototype.showToast = function (params) {
        // O1HD.getManagers().uiMgr.showMessageBox(params.title);
    };
    NativeApi.prototype.showLoading = function (params) {
        console.log('h5 显示进度', params);
    };
    NativeApi.prototype.hideLoading = function () {
        console.log('h5 隐藏进度');
    };
    NativeApi.prototype.preCreateUnits = function () {
        // console.log(DEEP_NEXT_SPLIT, 'h5 预先创建');
    };
    NativeApi.prototype.loadAndShowVideoAd = function (successCallback, errorCallback, completeCallback) {
        //
        switch (cc.sys.os) {
            case cc.sys.OS_ANDROID: {
                // 调用 hello 方法
                // completeCallback && completeCallback();
                // window['lookOverF'] = completeCallback;
                jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "loadRewardingAd", "(Ljava/lang/String;)V", "native.androidCallVideoOver()");
                // cc.game.pause();
                // O1HD.getManagers().uiMgr.showLoading('正在加载视频');
                var dr_1 = setInterval(function () {
                    //@ts-ignore
                    var okNumber = jsb.reflection.callStaticMethod('org/cocos2dx/javascript/AppActivity', 'getAdWatchFlag', "(Ljava/lang/String;)I", "test");
                    console.log('cocos SDK 广告结果', okNumber);
                    if (okNumber == 1) {
                        clearInterval(dr_1);
                        // O1HD.getManagers().uiMgr.hideLoading();
                        // cc.game.resume();
                        //
                        successCallback && successCallback();
                        completeCallback && completeCallback();
                    }
                }, 100);
                break;
            }
            case cc.sys.OS_IOS: {
                console.log('cocos SDK 调用苹果激励视频', this.m_adUnitId);
                //苹果代码并没有使用此ID
                jsb.reflection.callStaticMethod('RootViewController', 'loadRewardVideo:', this.m_adUnitId);
                // cc.game.pause();
                // O1HD.getManagers().uiMgr.showLoading('正在加载视频');
                var dr_2 = setInterval(function () {
                    //@ts-ignore
                    var okNumber = jsb.reflection.callStaticMethod('RootViewController', 'getRewardLookOver');
                    console.log('cocos SDK 广告结果', okNumber);
                    if (okNumber) {
                        clearInterval(dr_2);
                        // O1HD.getManagers().uiMgr.hideLoading();
                        // cc.game.resume();
                        //
                        successCallback && successCallback();
                        completeCallback && completeCallback();
                    }
                }, 100);
                break;
            }
            default: {
                successCallback && successCallback();
                completeCallback && completeCallback();
                break;
            }
        }
    };
    NativeApi.prototype.authorize = function (params) {
        params.success && params.success();
    };
    NativeApi.prototype.login = function (params) {
        params.success && params.success({ code: null });
    };
    NativeApi.prototype.gameRecordStart = function (params, onStart) {
        console.log('h5 录屏start');
        onStart && onStart(null);
    };
    NativeApi.prototype.gameRecordStop = function () {
        console.log('h5 录屏stop');
        return true;
    };
    NativeApi.prototype.shareGameRecordVideo = function (successCb, failCb) {
        console.log('h5 分享录屏');
    };
    NativeApi.prototype.isProduction = function () {
        if (cc.sys.isMobile) {
            return true;
        }
        return false;
    };
    NativeApi.prototype.isHaveShareVideo = function () {
        return false;
    };
    NativeApi.prototype.reportAnalytics = function (EventKey, data) {
        // console.log('native 发送埋', analytics.getKey(), analytics.getObj());
        switch (cc.sys.os) {
            case cc.sys.OS_ANDROID: {
                // jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "eventListener", "(Ljava/lang/String;Ljava/lang/String;)V", analytics.getKey(), analytics.getObj().src);
                // jsb.reflection.callStaticMethod('RootViewController', 'reportAnalytics:valueString:', analytics.getKey(), analytics.getObj().src);
                break;
            }
            case cc.sys.OS_IOS: {
                // console.log('cocos SDK 调用苹果', analytics.getKey(), analytics.getObj().src);
                // jsb.reflection.callStaticMethod('RootViewController', 'reportAnalytics:valueString:', analytics.getKey(), analytics.getObj().src);
                break;
            }
            default: {
                break;
            }
        }
        return;
    };
    NativeApi.prototype.clearMemory = function () {
    };
    NativeApi.prototype.shareAppMessage = function (args) {
        // O1HD.getManagers().uiMgr.showMessageBox('分享请从微信小游戏进入');
    };
    NativeApi.prototype.showModal = function (params) {
    };
    return NativeApi;
}(miniApp_1.default));
exports.default = NativeApi;

cc._RF.pop();